package top.yueyazhui.business.service.impl;

import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yueyazhui.business.feign.OrderFeign;
import top.yueyazhui.business.feign.StorageFeign;
import top.yueyazhui.business.service.BusinessService;

@Service
public class BusinessServiceImpl implements BusinessService {

    @Autowired
    OrderFeign orderFeign;
    @Autowired
    StorageFeign storageFeign;

    @Override
    @GlobalTransactional
    public void purchase(String userId, String commodityCode, Integer count, Double money) {
        storageFeign.deductStorage(commodityCode, count);
        orderFeign.addOrder(userId, commodityCode, count, money);
    }
}
